package com.demo.rydemo.jwt.model;

import lombok.Builder;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author ry
 * @Description
 * @Date 2020/8/12 23:24
 */
@Builder
public class JwtUser {
    private Long userId; //用户id

    private String userName; //用户名

    private JwtUserEnum userEnum; // 用户类型 也可以标识为来源

    private String roles; // 用户角色   // 可选使用

    private String userLoginCode;  //自定义登录码  可选使用

    private Map<String, String> extInfos;  // 扩展信息  可选使用

    public Map<String, String> getExtInfos() {
        return extInfos;
    }

    public void setExtInfos(Map<String, String> extInfos) {
        this.extInfos = extInfos;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserLoginCode() {
        return userLoginCode;
    }

    public void setUserLoginCode(String userLoginCode) {
        this.userLoginCode = userLoginCode;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public JwtUserEnum getUserType() {
        return userEnum;
    }

    public void setUserType(JwtUserEnum userType) {
        this.userEnum = userType;
    }

    public String getRoles() {
        return roles;
    }

    public void setRoles(String roles) {
        this.roles = roles;
    }

    public void putExtInfo(String key, String value) {
        if (extInfos == null) {
            extInfos = new HashMap<String, String>();
        }
        extInfos.put(key, value);
    }

    public String getExtInfo(String key) {
        if(extInfos == null) {
            return null;
        }

        return extInfos.get(key);
    }
}
